'use strict';

const Controller = require('../core/BaseController');

class UserController extends Controller {

  async lists() {
    const { userService } = this.ctx.service;

    await this.returnService(userService.lists());
  }

  async add() {
    const { userService } = this.ctx.service;
    // const { user_name, age, img } = this.ctx.request.body;
    const obj = {
      ...this.ctx.request.body,
      createTime: this.ctx.helper.formatTime(new Date())
    }

    await this.returnService(userService.add(obj));
  }

  async detail() {
    const { userService } = this.ctx.service;
    await this.returnService(userService.detail(this.ctx.params.id));
  }

}

module.exports = UserController;
